{
    TFile *f = new TFile("ggus_tickets_atlas_2010Nov.root");

    TTree *t = (TTree*)f->Get("Tree_GGUSInfo");

    /* Histograms for drawing */
    TH1F *h_tk_etime = new TH1F("solving time of GGUS tickets","",120,0.,30.);

    Int_t min_tk_etime = 999999999;
    Int_t max_tk_etime = 0;

    Char_t fqid[8];
    Char_t status[32];
    Char_t type[8];
    Char_t site[32];
    Char_t unit[32];

    Int_t ctime;
    Int_t utime;
    Int_t duration;
    Int_t priority;

    Float_t days;
    Float_t min_days = 365.;
    Float_t max_days = 0.;

    t->SetBranchAddress("fqid"   , fqid);
    t->SetBranchAddress("status" , status);
    t->SetBranchAddress("type"   , type);
    t->SetBranchAddress("site"   , site);
    t->SetBranchAddress("unit"   , unit);

    t->SetBranchAddress("ctime", &ctime);
    t->SetBranchAddress("utime", &utime);
    t->SetBranchAddress("duration", &duration);
    t->SetBranchAddress("priority", &priority);

    Int_t nentries = (Int_t)t->GetEntries();

    for ( Int_t i=0; i<nentries; i++) {
        t->GetEntry(i);

        days = (1.0 * duration) / 86400.; 

        cout << "==> Entry " << i << endl;
        cout << "\tfqid     : " << fqid     << endl;
        cout << "\tstatus   : " << status   << endl;
        cout << "\ttype     : " << type     << endl;
        cout << "\tsite     : " << site     << endl;
        cout << "\tunit     : " << unit     << endl;
        cout << "\tctime    : " << ctime    << endl;
        cout << "\tutime    : " << utime    << endl;
        cout << "\tduration : " << duration << "(" << days << " days)" << endl;
        cout << "\tpriority : " << priority << endl;
        cout << ""   << endl;

        if ((strcmp(status, "solved") == 0) || (strcmp(status,"verified") == 0)) {
            if ( duration < min_tk_etime ) min_tk_etime = duration;
            if ( duration > max_tk_etime ) max_tk_etime = duration;
            if ( days < min_days ) min_days = days;
            if ( days > max_days ) max_days = days;

            h_tk_etime->Fill(days);
        }
    }

    // entities summary 
    cout << "==> Summary " << endl;
    cout << "\tduration (min:max) : " << min_tk_etime << " : " << max_tk_etime << endl;
    cout << "\tdays     (min:max) : " << min_days << " : " << max_days << endl;

    TCanvas *c = new TCanvas("c","Ticket Duration",0,0,800,600);
    c->Divide(1,1);

    c->cd(1);
    gPad->SetGrid();
    gPad->SetLogx();
    h_tk_etime->GetXaxis()->Set(120, 0, 30);
    h_tk_etime->GetXaxis()->SetTitle("days");
    h_tk_etime->GetYaxis()->SetTitle("# tickets");
    h_tk_etime->SetFillColor(16);
    h_tk_etime->Draw();

    //c->cd(2);
    //h_app_etime->GetXaxis()->Set(100, 0., max_app_etime);
    //h_app_etime->SetFillColor(16);
    //h_app_etime->Draw();
}
